<%@ page language="java" isELIgnored="false" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/ResourceGlobal.jsp"%>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>招商财富Solution - 登录</title>
		<link rel="stylesheet" type="text/css" href="<%=context%>resources/modules/bootstrap/css/index/login.css?201903120914" />
		<script type="text/javascript">
			if (window != top) {
				window.top.location = "/scbp/index/loginPage.do";
			}
			console.log('${logoutRs}');
		</script>
	</head>
	<body>
		<div class="navbar navbar-static-top login-navbar">
			<div class="container">
				<div class="navbar-header">
					<a href="javascript:void(0);" class="navbar-brand"><img src="<%=context%>resources/modules/bootstrap/css/index/images/logo.png"></a>
				</div>
				<nav id="bs-navbar" class="collapse navbar-collapse">
					<ul class="nav navbar-nav">
						<li></li>
					</ul>
					<ul class="nav navbar-nav navbar-right">
						<span class="customer-phone">
							<img alt="电话" src="<%=context%>resources/modules/bootstrap/css/index/images/iphone.png">
							&nbsp;客服电话：400-8878-555
						</span>
					</ul>
				</nav>
			</div>
		</div>
		<div class="login">
			<div class="container" style="min-height: 320px;">
				<div class="login-panel">
	                <h2>登录</h2>
	                <div class="panel-input">
	                	<span class="input-icon"><img src="<%=context%>resources/modules/bootstrap/css/index/images/login_user.png"></span>
	                    <input type="text" placeholder="用户名" id="loginName" autocomplete="off" autofocus="autofocus">
	                </div>
	                <div class="panel-input">
	                	<span class="input-icon"><img src="<%=context%>resources/modules/bootstrap/css/index/images/login_password.png"></span>
	                    <input type="password" placeholder="密码" id="loginPwd" autocomplete="off">
	                </div>
	                <div class="panel-input">
	                	<span class="input-icon"><img src="<%=context%>resources/modules/bootstrap/css/index/images/login_verify.png"></span>
	                    <input type="text" class="captcha" id="verifyCode" placeholder="验证码" autocomplete="off">
						<img src="/scbp/captcha/get.do?r=${r}" id="captchaImg" class="captcha-text" onclick="getRandomCode()">
	                </div>
	                <div class="panel-btn clear">
	                    <button type="button" id="submit_btn" class="btn btn-login btn-primary" data-loading-text="登录中...">登 录</button>
						<span class="message_text"></span>
	                </div>
				</div>
			</div>
		</div>
		<div class="footer-message clear">
			<div class="message">
				<div class="icon service"></div>
				<div class="msg"><p>销售热线：0755-23988886</p></div>
			</div>
			<div class="message">
				<div class="icon email"></div>
				<div class="msg"><p>邮箱：cmwa@cmwachina.com</p></div>
			</div>
			<div class="message">
				<div class="icon address"></div>
				<div class="msg"><p>地址：深圳市福田区东海国际中心B座3楼</p></div>
			</div>
		</div>
		<div class="login-footer">
			<div class="text-center"><strong>ICP许可证号：粤ICP备13033404号-1 版权所有 &copy;2019  招商财富资产管理有限公司</strong></div>
		</div>
		
		<script type="text/javascript">
			var loginPath = '<%=context%>';
		
			$(function(){
				var height = document.body.clientHeight;
				$('.login').css('height', height - 347);
				$('.login .container').css('height', height - 347);
				$(window).resize(function() {
				  var height = document.body.clientHeight;
				  $('.login').css('height', height - 347);
				  $('.login .container').css('height', height - 347);
				});
				$("#loginName").focus();
				window.docObj = {};
				window.login = {
					init : function(){
						docObj.checkLoginNameAndPwd();
					},
					/**
					 * 按钮点击验证密码
					 */
					checkLoginNameAndPwd:function(){
						var btn = $("#submit_btn");
						btn.click(function(){
							$(".message_text").text("");
							getUserInfoByIdAndPwd();
						});
					}
				};
				docObj = $.extend({},login);
				docObj.init();
	
				// 回车验证密码
				$(document).keydown(function(event) {
					if (event.keyCode == 13) {
						getUserInfoByIdAndPwd();
					}
				}); 
			});
	
			function fastLogin(username) {
				$("#loginName").val(username);
				getUserInfoByIdAndPwd();
			}
	
			function getUserInfoByIdAndPwd(){
				var loginName = $.trim($("#loginName").val());
				var	loginPwd = $.trim($("#loginPwd").val());
				var	verifyCode = $.trim($("#verifyCode").val());
				if(loginName == ''){
					$(".message_text").text("请输入用户名！");
					$("#loginName").focus();
					return;
				}
				if(loginPwd == ''){
					$(".message_text").text("请输入密码！");
					$("#loginPwd").focus();
					return;
				}
				if(verifyCode == ''){
					$(".message_text").text("请输入验证码！");
					$("#verifyCode").focus();
					return;
				}
				if(loginName != '' && loginPwd != '' && verifyCode != ''){
					$("#submit_btn").button('loading');
					$.ajax({
						url : loginPath + "index/login.do",
						type : "post",
				        dataType : "json",
				        data:{
							'loginName'	: loginName,
							'loginPwd'	: loginPwd,
							'verifyCode': verifyCode,
							},
						cache: false,
						async: true,
						success : function(data) {
				        	if(data.success){
				        		$(".message_text").text(data.message);
				        		$(".message_text").css("color",'green');
				        		window.location.href = loginPath + "index/indexView.do";
				        	} else {
				        		$(".message_text").text(data.message);
				        		getRandomCode();
				        		$("#submit_btn").button('reset');
				        	}
				        },
				        error : function(err) {
				        	$(".message_text").text("系统错误，登录异常");
				        	getRandomCode();
			        		$("#submit_btn").button('reset');
				        }
					});
				}
			}
	
			function getRandomCode() {
				$("#verifyCode").val("");
				$("#captchaImg").attr("src", loginPath + "captcha/get.do?r=" + new Date().getTime());
			}
		</script>
	</body>
</html>